<template>
  <!-- --- 订单评审 --- -->
  <div class="incolumn">
    <div class="incolumn_countr">
      <div class="block">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="输入搜索" class="s1">
            <el-input v-model="formInline.key" placeholder="请输入合作公司" style="width:150%"></el-input>
          </el-form-item>
          <el-form-item label="输入时间" label-width="230px">
            <el-date-picker
              v-model="formInline.time1"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @change="chage"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onsubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- ============================================================ -->
    <!-- ================== 列 表 表 单 ====================== -->
    <!-- ============================================================ -->
    <div class="incolumn_from">
      <el-table :data="tableData" style="width: 100%;" :height="autoHeightTable" stripe>
        <el-table-column label="序号" align="center" type="index" width="70"></el-table-column>
        <el-table-column prop="syear" label="年份" align="center" width="200"></el-table-column>
        <el-table-column prop="smonth" label="月份" align="center"></el-table-column>
        <el-table-column prop="plannums" label="销售计划" align="center"></el-table-column>
        <el-table-column prop="factnums" label="实际数量" align="center"></el-table-column>
        <el-table-column prop="createon" label="创建时间" align="center"></el-table-column>
        <el-table-column prop="preparename" label="制单人" align="center"></el-table-column>
        <el-table-column prop="states" label="状态" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              @click="Apply(scope.row)"
              v-show="scope.row.states == '待查看'"
              type="warning"
              size="small"
            >查看</el-button>
            <el-button @click="Apply" type="primary" size="small">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="bottom_slate">
        <el-pagination
          background
          layout="prev, pager, next"
          :current-page="current"
          :page-size="pagesize"
          @current-change="handleCurrentChange"
          :total="total"
        ></el-pagination>
      </div>
      <!-- ============================================================ -->
      <!-- -========查看弹框========= --- -->
      <!-- ============================================================ -->
      <el-dialog :visible.sync="dialogTableVisible" :modal-append-to-body="false" width="1850px">
        <div class="side_1"></div>
        <span class="add_1">销售计划</span>
        <div class="addplan_box">
          <div class="from_sex">
            <el-row :gutter="5">
              <el-col :span="4">
                <el-form :model="formInline" class="demo-form-inline" label-width="83px">
                  <el-form-item label="计划年份">
                    <el-input v-model="formInline.a"></el-input>
                  </el-form-item>
                </el-form>
              </el-col>
              <el-col :span="4">
                <el-form :model="formInline" class="demo-form-inline" label-width="83px">
                  <el-form-item label="计划月份">
                    <el-input v-model="formInline.b"></el-input>
                  </el-form-item>
                </el-form>
              </el-col>
              <el-col :span="4">
                <el-form :model="formInline" class="demo-form-inline" label-width="83px">
                  <el-form-item label="编号">
                    <el-input v-model="formInline.c"></el-input>
                  </el-form-item>
                </el-form>
              </el-col>
              <div class="from_btn">
                <el-button type="warning" size="mini" @click="dialogVisible=true">周计划</el-button>
              </div>
            </el-row>
          </div>
          <div class="addplan_table">
            <template>
              <el-table :data="tableDataTy">
                <el-table-column type="index" label="序号" prop="xuhao" align="center" width="79"></el-table-column>
                <el-table-column label="主机厂" align="center" width="100">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.main"></el-input>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="产品图号" width="100">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.pic"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="产品名称" align="center" width="100">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.name"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="f" label="销量需求" align="center" width="100">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.need"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="需求时间及数量" align="center">
                  <el-table-column prop="one" label="1" align="center" width="30"></el-table-column>
                  <el-table-column prop="two" label="2" align="center" width="30"></el-table-column>
                  <el-table-column prop="three" label="3" align="center" width="30"></el-table-column>
                  <el-table-column prop="four" label="4" align="center" width="30"></el-table-column>
                  <el-table-column prop="five" label="5" align="center" width="30"></el-table-column>
                  <el-table-column prop="six" label="6" align="center" width="30"></el-table-column>
                  <el-table-column prop="seven" label="7" align="center" width="30"></el-table-column>
                  <el-table-column prop="eight" label="8" align="center" width="30"></el-table-column>
                  <el-table-column prop="nine" label="9" align="center" width="30"></el-table-column>
                  <el-table-column prop="ten" label="10" align="center" width="30"></el-table-column>
                  <el-table-column prop="eleven" label="11" align="center" width="30"></el-table-column>
                  <el-table-column prop="twelve" label="12" align="center" width="30"></el-table-column>
                  <el-table-column prop="thirteen" label="13" align="center" width="30"></el-table-column>
                  <el-table-column prop="fourteen" label="14" align="center" width="30"></el-table-column>
                  <el-table-column prop="fifteen" label="15" align="center" width="30"></el-table-column>
                  <el-table-column prop="sixteen" label="16" align="center" width="30"></el-table-column>
                  <el-table-column prop="seventeen" label="17" align="center" width="30"></el-table-column>
                  <el-table-column prop="eighteen" label="18" align="center" width="30"></el-table-column>
                  <el-table-column prop="nineteen" label="19" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty" label="20" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-one" label="21" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-two" label="22" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-three" label="23" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-four" label="24" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-five" label="25" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-six" label="26" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-seven" label="27" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-eight" label="28" align="center" width="30"></el-table-column>
                  <el-table-column prop="twenty-nine" label="29" align="center" width="30"></el-table-column>
                  <el-table-column prop="thirty" label="30" align="center" width="30"></el-table-column>
                </el-table-column>
                <el-table-column prop="sum" label="本月合计" align="center" width="120"></el-table-column>
                <el-table-column prop="note" label="备注" align="center" width="100"></el-table-column>
              </el-table>
            </template>
          </div>
        </div>
        <el-dialog
          title
          :visible.sync="dialogVisible"
          width="55%"
          :modal-append-to-body="false"
          :close-on-click-modal="false"
        >
          <div class="table_dia">
            <el-table :data="tableDatas" border>
              <el-table-column prop="first" label="第一周(2日-8日)" align="center"></el-table-column>
              <el-table-column prop="second" label="第二周(9日-15日)" align="center"></el-table-column>
              <el-table-column prop="third" label="第三周(16日-22日)" align="center"></el-table-column>
              <el-table-column prop="fourth" label="第四周(22日-23日)" align="center"></el-table-column>
              <el-table-column prop="fifth" label="第五周(24日-30日)" align="center"></el-table-column>
            </el-table>
          </div>
        </el-dialog>
        <div class="box_btn">
          <el-button @click="Confirm" type="primary">确认</el-button>
          <el-button class="bm_btn" @click="dialogTableVisible = false" type="info">返回</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  computed: {
    autoHeightTable() {
      return document.documentElement.scrollHeight - 251 - 78;
    }
  },
  data() {
    return {
      dialogTableVisible: false,
      formInline: {
        key: ""
      },
      tableData: [{}],
      tableDataBa: [],
      formInlineBy: {},
      //分页
      start: "",
      end: "",
      total: 1,
      current: 1,
      pagesize: 10,
      //弹框
      dialogVisible: false,
      tableDataTy: [
        {
          xuhao: "1",
          main: "江淮客车",

          pic: "Yu-8776",
          name: "车盖",
          need: "1000",
          one: "",
          two: "10",
          eleven: "10",
          thirteen: "11",
          sum: "200"
        },
        {
          main: "江淮客车",

          pic: "Yu-8776",
          name: "车盖",
          need: "1000",
          one: "",
          three: "10",
          nineteen: "10",
          fourteen: "11",
          sum: "200"
        },
        {
          main: "江淮客车",

          pic: "Yu-8776",
          name: "车盖",
          need: "1000",
          one: "",
          three: "10",
          nineteen: "10",
          fourteen: "11",
          sum: "200"
        },
        {
          main: "江淮客车",

          pic: "Yu-8776",
          name: "车盖",
          need: "1000",
          one: "",
          three: "10",
          nineteen: "10",
          fourteen: "11",
          sum: "200"
        }
      ],
      tableDatas: [
        {
          first: "34",
          second: "",
          third: "",
          fourth: "",
          fifth: "34"
        },
        {
          first: "34",
          second: "34",
          third: "",
          fourth: "34",
          fifth: ""
        },
        {
          first: "34",
          second: "34",
          third: "",
          fourth: "34",
          fifth: ""
        },
        {
          first: "34",
          second: "34",
          third: "",
          fourth: "34",
          fifth: ""
        },
        {
          first: "34",
          second: "34",
          third: "",
          fourth: "34",
          fifth: ""
        },
        {
          first: "34",
          second: "34",
          third: "",
          fourth: "34",
          fifth: ""
        }
      ]
    };
  },
  created() {
    this.getData(0);
    this.getDatas();
  },
  methods: {
    //表单接口
    getData(page) {
      var obj = {
        start: this.start,
        end: this.end,
        key: this.formInline.key,
        pn: page,
        PerPageSize: 10
      };
      var objs = JSON.stringify(obj);
      console.log(objs);
      var empno = JSON.parse(localStorage.getItem("enterpristList")).empno;
      axios(
        "/apis/PurchasingManagement.asmx/List_Purchasing?index=5&jsondata=" +
          objs +
          "&empno=" +
          empno
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        var list = JSON.parse(datas.string.__text);
        console.log(11111111111111111111111111111111111111111);
        console.log(list);
        this.tableData = [];
        this.tableData = list;
      });
    },
    getDatas() {
      var obj = {
        start: "",
        end: "",
        key: this.formInline.key,
        pn: 0,
        PerPageSize: 10000
      };
      var objs = JSON.stringify(obj);
      var empno = JSON.parse(localStorage.getItem("enterpristList")).empno;
      axios(
        "/apis/PurchasingManagement.asmx/List_Purchasing?index=5&jsondata=" +
          objs +
          "&empno=" +
          empno
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        var list = JSON.parse(datas.string.__text);
        this.total = list.length;
      });
    },
    //分页
    handleCurrentChange(e) {
      this.getData(e - 1);
    },
    // 日期改变
    chage(e) {
      console.log(e);
      if (e) {
        this.start =
          e[0].getFullYear() +
          "-" +
          (e[0].getMonth() + 1) +
          "-" +
          e[0].getDate();
        this.end =
          e[1].getFullYear() +
          "-" +
          (e[1].getMonth() + 1) +
          "-" +
          e[1].getDate();
      } else {
        this.start = "";
        this.end = "";
      }
    },
    // 筛选
    onsubmit() {
      this.getData(0);
    },
    //查看
    Apply() {
      this.dialogTableVisible = true;
      axios(
        "/apis/PurchasingManagement.asmx/Save_Purchase?index=5" + empno
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        var list = JSON.parse(datas.string.__text);
      });
    },
    //确认
    Confirm() {
      this.dialogTableVisible = false;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
//第一块儿
.incolumn_countr {
  margin-left: 15px;
  height: 50px;
  width: 97%;
  background-color: white;
  padding-top: 10px;
}
.block {
  margin-left: 20px;
  cursor: pointer;
}
.block_Math {
  cursor: pointer;
}

//第二块
.incolumn_from {
  margin-top: 15px;
  margin-left: 15px;
  width: 98%;
  height: 100%;
}
// 弹框
.from_bt {
  margin-top: -20px;
  margin-left: 10px;
  font-size: $font-size-medium-x;
  font-weight: bold;
}

.herd_bud {
  margin-top: -40px;
  height: 20px;
  width: 5px;
  background-color: rgb(52, 144, 231);
}
.Purchase_Division {
  border: 0.5px solid $linecolor;
}

.tab_idx {
  margin-top: 40px;
  font-size: $font-size-medium;
  font-weight: bold;
}

.zt1 {
  border: 1px solid $linecolor;
  height: 40px;
  width: 200px;
  text-align: center;
  border-radius: 15px;
  cursor: pointer;
  outline: none;
}
.zt2 {
  border: 1px solid $linecolor;
  height: 40px;
  width: 200px;
  text-align: center;
  border-radius: 15px;
  cursor: pointer;
  margin-left: 30px;
  outline: none;
}
.tab_ther {
  margin-top: 30px;
}
.from_ipt_wb {
  height: 40px;
  width: 15%;
  border: none;
  border: 1px solid $linecolor;
  border-radius: 4px;
  text-align: center;
}
.from_zt1 {
  margin-left: 40px;
}
.bottom_slate {
  height: 60px;
  line-height: 40px;
  text-align: center;
}
///弹框计划

.side_1 {
  width: 5px;
  height: 16px;
  background-color: $Header_color;
  margin-left: 10px;
  margin-top: -20px;
}
.add_1 {
  margin-left: 20px;
  margin-top: -20px;
  float: left;
  font-size: 18px;
  font-weight: 400;
}
.btn_fanhui {
  margin-top: -20px;
  margin-right: 20px;
  float: right;
}
.addplan_box {
  background: $white;
  width: 98%;
  //   padding: 0 1%;
  margin-top: 50px;
  margin-left: 10px;
  border: 1px solid $bordercolor;
  border-radius: 4px;
  height: 550px;
  .addplan_table {
    margin-top: 30px;
    width: 98%;

    margin-left: 10px;
  }
}
.btn {
  float: right;
}
.from_sex {
  margin-top: 20px;
}
.from_btn {
  float: right;
  padding-right: 20px;
}
.box_btn {
  margin-top: 20px;
  text-align: center;
}
</style>